﻿var status;
var newhandMap = 910000000;     // 新手地图
var SteppedSnailMap = 960000100;
var changeJobMap = 910000000;   // 转职地图
var text;
var a = "#fEffect/CharacterEff/1114000/1/0#"; //红色六芒星
function start() {
    status = -1;
    action(1, 0, 0);
}

function action(mode, type, selection) {
    if (mode == -1) {
        cm.dispose();
    } else {
        if (mode == 0 && status == 0) {
            cm.dispose();
            return;
        }
        if (mode == 1)
            status++;
        else {
            cm.dispose();
            return;
        }

        if (status == 0) {
            text = a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + "\r\n\r\n";
            text += " #d尊敬的[ #r#h ##d ] 玩家 - 欢迎光临 #b" + cm.getServerName() + "#k\r\n";
            text += " #d不一样的冒险岛体验让您玩的舒心享受快乐 #b欢迎您入住#k\r\n";
            text += " #d请玩家自行进入新手系统升到10级开始旅途 #b踏上旅途吧#k\r\n\r\n";
            text += a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + "\r\n\r\n";
			cm.sendOkS(text,1);
            if (cm.getMapId() != newhandMap) {
                cm.dispose();
                return;
            }
        } else if (status == 1) {
            text = "\r\n\r\n\t尊敬的 [ #r#h ##k ] 开始您的愉快旅途吧";
            cm.sendYesNo(text);
        } else if (status == 2) {
            var em = cm.getEventManager("SteppedSnail");
            if (em == null) {
                cm.sendOk("副本出错，请联系GM");
                cm.dispose();
                return;
            }

            var eim = em.newInstance(cm.getPlayer().getName());
            var map = eim.createInstanceMapS(SteppedSnailMap);
            var player = cm.getPlayer();
            var tomap = em.getMapFactory().getMap(changeJobMap);
            eim.registerPlayer(player);
            player.changeMap(map, map.getPortal(0));
            eim.startEventTimer(60000);
            cm.getConnection().prepareStatement("DELETE FROM rankingtop where rankingname ='潜能检测系统' and characterid ='" + cm.getPlayer().getId() + "'").executeUpdate();
            cm.useItem(2003517); // 新手赠送一个超级巨人
            cm.worldBrodcastEffect(5121037, "[ 新手系统 ] : 欢迎[" + cm.getName() + "] 从火星中掉到了" + cm.getServerName() + "国度●ω●");
            cm.worldMessageYellow("[ 新手公告 ] : 欢迎[" + cm.getPlayer().getName() + "]从火星中掉到了" + cm.getServerName() + "国度●ω●");
            cm.dispose();
        }
    }
}